<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title  am-cf" style="font-size: 20px;">创建广告</div>
                    <div class="am-u-lg-3 tpl-index-settings-button" style="float: right;width: 100%;">
                        <a href="{:url('Advertise/buy')}"">
                            <button type="button" class="page-header-button">购买浏览数</button>
                        </a>
                        <span class="" style="float: right; font-size: 18px;margin:12px 5% 0 0;">当前剩余浏览数:<b style="color: red;padding-left:50px;">{$user.adnum}个</b></span>
                    </div>
                </div>
                <div class="widget-body am-fr">
                    <div class="am-tabs" data-am-tabs>
                      <ul class="am-tabs-nav am-nav am-nav-tabs">
                        <li class="am-active"><a href="#tab3">图文创建</a></li>
                        <li><a href="#tab2">链接创建</a></li>
                      </ul>
                      <div class="am-tabs-bd" style="border: 0;">
                        <div class="am-tab-panel am-fade am-in am-active" id="tab3" style=" margin-bottom: 80px;">
                            <form class="am-form tpl-form-line-form">
                                {:token()}
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">标题 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" id="user-name" placeholder="请填写标题文字10-20字左右。">
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-intro" class="am-u-sm-3 am-form-label">文章内容</label>
                                    <div class="am-u-sm-9">
                                        <textarea class="" rows="10" id="ling" placeholder="请输入文章内容"></textarea>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-weibo" class="am-u-sm-3 am-form-label">封面图</label>
                                    <div class="am-u-sm-9">
                                        <div class="am-form-group am-form-file" style="width: 50%;">
                                            <div class="tpl-form-file-img">
                                                <img class="am-img-thumbnail" id="showImg" style="width: 65%;border: none;">
                                            </div>
                                             <input type="hidden" name="images" value="" id="images">
                                            <div class="am-form-group am-form-file">
                                            <button type="button" id="test1" class="am-btn am-btn-danger am-btn-sm layui-btn">
                                               
                                                <i class="am-icon-cloud-upload"></i> 添加封面图片
                                            </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label"style="padding: 0px;">可用浏览数</label>
                                    <div class="am-u-sm-9">
                                        <b>{$user.adnum}</b>
                                        <a type="button" href="{:url('Advertise/buy')}" class="am-btn am-btn-warning am-round" style=" margin-left: 20px;">立即购买</a>
                                    </div>

                                </div>
                                <div class="am-form-group">
                                    <label class="am-u-sm-3 am-form-label">发布浏览数</label>
                                    <div class="am-u-sm-9">
                                        <input type="number" id="totalnum" placeholder="请输入发布数量">
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">性别</label>
                                    <div class="am-u-sm-9">
                                        <select data-am-selected="{searchBox: 0}" style="display: none;">
                                            <option value="c">请选择</option>
                                            <option value="a">男</option>
                                            <option value="b">女</option>
                                            <option value="o">未知</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">年龄</label>
                                    <div class="am-u-sm-9">
                                        <select data-am-selected="{searchBox: 0}" style="display: none;">
                                            <option value="c">请选择</option>
                                            <option value="a">
                                                <20</option>
                                                    <option value="b">21~30</option>
                                                    <option value="d">30~50</option>
                                                    <option value="o">50></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">国家</label>
                                    <div class="am-u-sm-9">
                                        <select data-am-selected="{searchBox: 0}" style="display: none;">
                                            <option value="c">请选择</option>
                                            <option value="a">中国</option>
                                            <option value="b">法国</option>
                                            <option value="o">美国</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">语言</label>
                                    <div class="am-u-sm-9">
                                        <select data-am-selected="{searchBox: 0}" style="display: none;">
                                            <option value="c">请选择</option>
                                            <option value="a">中文</option>
                                            <option value="b">法文</option>
                                            <option value="o">英文</option>
                                        </select>
                                    </div>
                                </div>
                                
                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                       <input class="am-btn am-btn-warning" type="button" name="btn" id="imgestext" value="提交"  onclick="settime(this);" style=" background: #0c79b1;border-color:#0c79b1;cursor: pointer;"/>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="am-tab-panel am-fade" id="tab2"style=" margin-bottom: 80px;">
                             <form class="am-form tpl-form-line-form">
                                {:token()}
                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">标题 </label>
                                    <div class="am-u-sm-9">
                                        <input type="text" class="tpl-form-input" id="name" placeholder="请填写标题文字10-20字左右。">
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label class="am-u-sm-3 am-form-label">您想推广的网站链接</label>
                                    <div class="am-u-sm-9">
                                        <input type="text" id="link" placeholder="http://">
                                    </div>
                                </div>
                                 <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label"style="padding: 0px;">可用浏览数</label>
                                    <div class="am-u-sm-9">
                                        <b>{$user.adnum}</b>
                                        <a type="button" class="am-btn am-btn-warning am-round" style=" margin-left: 20px;">立即购买</a>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label class="am-u-sm-3 am-form-label">发布浏览数</label>
                                    <div class="am-u-sm-9">
                                        <input type="number" id="totalnum_link">
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">性别</label>
                                    <div class="am-u-sm-9">
                                        <select data-am-selected="{searchBox: 0}" style="display: none;">
                                            <option value="c">请选择</option>
                                            <option value="a">男</option>
                                            <option value="b">女</option>
                                            <option value="o">未知</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">年龄</label>
                                    <div class="am-u-sm-9">
                                        <select data-am-selected="{searchBox: 0}" style="display: none;">
                                            <option value="c">请选择</option>
                                            <option value="a">
                                                <20</option>
                                                    <option value="b">21~30</option>
                                                    <option value="d">30~50</option>
                                                    <option value="o">50></option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">国家</label>
                                    <div class="am-u-sm-9">
                                        <select data-am-selected="{searchBox: 0}" style="display: none;">
                                            <option value="c">请选择</option>
                                            <option value="a">中国</option>
                                            <option value="b">法国</option>
                                            <option value="o">美国</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">语言</label>
                                    <div class="am-u-sm-9">
                                        <select data-am-selected="{searchBox: 0}" style="display: none;">
                                            <option value="c">请选择</option>
                                            <option value="a">中文</option>
                                            <option value="b">法文</option>
                                            <option value="o">英文</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <input class="am-btn am-btn-warning" id="imgeslink" type="button" name="btn"  value="提交"  onclick="settime(this);" style=" background: #0c79b1;border-color:#0c79b1;cursor: pointer;"/>
                                    </div>
                                </div>
                            </form>
                        </div>
                      </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

 <script src="__CDN__/assets/less/layui/layui.js"></script>
<script type="text/javascript">
    var countdown=5;  
    function settime(val) {  
        if (countdown == 0) {  
            val.removeAttribute("disabled");  
            val.value="提交";  
            countdown = 5;  
            return false;  
        } else {  
            val.setAttribute("disabled", true);  
            val.value="提交中";  
            countdown--;  
        }  
        setTimeout(function() {  
            settime(val);  
        },1000);  
    }
    layui.use('upload', function(){
      var upload = layui.upload;
       
      //执行实例
      var uploadInst = upload.render({
        elem: '#test1', //绑定元素
        size:500
        ,url: '/index/common/upload' //上传接口
        ,done: function(res, index, upload){
          //如果上传失败
          
          if(res.data==''||res.data==null){
              return layer.msg(res.msg);
          }else{
              
               document.getElementById("showImg").src= res.data.url; //图片链接（base64）.src = res.data.url;
               document.getElementById("images").value=res.data.url;
               return layer.msg("上传成功");
          }
          if(res.code = 0){
             return layer.msg('上传失败');
          }else{
              document.getElementById("showImg").src= res.data.url; //图片链接（base64）.src= res.data.url
              document.getElementById("images").value=res.data.url;
             return layer.msg('上传成功');
          }
         
          //上传成功
        }
      });
    });
</script>
 <style type="text/css">
    .theme-black .am-form input[type=color]:focus, .am-form input[type=date]:focus, .am-form input[type=datetime-local]:focus, .am-form input[type=datetime]:focus, .am-form input[type=email]:focus, .am-form input[type=month]:focus, .am-form input[type=number]:focus, .am-form input[type=password]:focus, .am-form input[type=search]:focus, .am-form input[type=tel]:focus, .am-form input[type=text]:focus, .am-form input[type=time]:focus, .am-form input[type=url]:focus, .am-form input[type=week]:focus, .am-form select:focus, .am-form textarea:focus, .am-form-field:focus {
        background-color: inherit;
        border-color: #3bb4f2;
        outline: 0;
        -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 5px rgba(59,180,242,.3);
        box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 5px rgba(59,180,242,.3);
    }
</style>
{include file="common/script" /}